package msu.ml.gis;

import msu.ml.data.*;
import java.io.*;
import java.awt.geom.Rectangle2D;

/**
 * The point class represents a geometric
 * point in the GIS system.
 *
 * @author Reginald M Mead
 * @version 1.0
 */
public class Point extends Shape {

	private double x;
	private double y;

	/**
	 * Create a new point with the specified
	 * x, y coordinates.
	 *
	 * @param x x coordinate for this point
	 * @param y y coordinate for this point
	 */
	public Point(double x, double y)
	{
		this.x = x;
		this.y = y;
	}

	
	/**
	 * Get the length of this shape record
	 * in 16bit words
	 *
	 * @return length in 16bit words
	 */
	public int getContentLength(){
		return 10;
	}

	/**
	 * Get the shape type for this shape
	 *
	 * @return the shape type for this shape
	 */
	public int getShapeType(){
		return 1;
	}

	/** 
	 * Get the X coordinate of this point
	 *
	 * @return the X coordinate for this point
	 */
	public double getX(){
		return x;
	}

	/** 
	 * Get the Y coordinate of this point
	 *
	 * @return the Y coordinate for this point
	 */
	public double getY(){
		return y;
	}

	/**
	 * Set the X coordinate for this point
	 * 
	 * @param newVal the X coordinate
	 */
	public void setX(double newVal){
		x = newVal;
	}

	/**
	 * Set the Y coordinate for this point
	 * 
	 * @param newVal the Y coordinate
	 */
	public void setY(double newVal){
		y = newVal;
	}

	/**
	 * Write this point to the specified output stream
	 *
	 * @param out output stream to write point to
	 */
	public void serialize(LittleEndianDataOutputStream out) throws IOException
	{
		out.writeDoubleLE(x);
		out.writeDoubleLE(y);
	}

	/**
	 * Get the Bounding Box for this shape
	 *
	 * @return the bounding box for this shape
	 */
	public Rectangle2D getBoundingBox()
	{
		return null;
	}
}
